<!DOCTYPE html>
<html>
<#include "/views/ftl/base/manager_include.ftl">
<script type="text/javascript" src="${basePath}js/My97DatePicker/WdatePicker.js"></script>
<base href="${basePath}">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户列表</title> 
<script type="text/javascript" charset="utf-8" src="ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="ueditor/ueditor.all.min.js"> </script> 
<script type="text/javascript" charset="utf-8" src="ueditor/lang/zh-cn/zh-cn.js"></script> 
</head>
<body style="background:#eef3f7;">
<#include "/views/ftl/base/head.ftl"> 
<div class="Main">
  <div class="dw">
<#include "/views/ftl/base/menu.ftl">
<#function a><#return "添加新闻_List"></#function> 

  <!--右边内容-->
      <div class="Rightbox fl">
        <!--面包屑-->
        <div class="Bread_crbs clear">
          <div class="Bread_crbs_img fl"></div>
          <div class="Bread_crbs_text fl"><a href="javascript:;"><span>内容管理</span></a><span class="fnt_famy">></span><a href="javascript:;"><span>添加内容页面</span></a></div>
        </div>  
        <!--各种表单设置-->
        <div class="bd_box">
         
          <div class="input_name">
            <span>内容标题: </span><input type="text" name="newsTitle" placeholder="请输入标题" value='' /> 
          </div><br/>
          <div class="input_name" style="display:none;">
            <span>自定义URI:</span><input type="text" name="customId" placeholder="使用字母,数字,下划线" value='' /><span>使用此URI访问.不填,使用默认id(最好不要用数字)</span>
          </div><br/>
           <div class="input_name"  style="display:none;">
            <span>浏览量:</span><input type="text" name="pageViews" placeholder="浏览量" value='' /><span>浏览量可修改</span>
          </div><br/> 
			<div class="input_name"><span>内容模块:</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
				<select name="newsModulesId" class="St">
					<option value="0">------------</option>
				</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			</div> 
			
    		<div class="input_name"><span>内容所属:</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
				<select name="isOutNews" class="St">
					<option value="0">站内内容</option>
					<option value="1">站外链接</option>
				</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			</div>
    	
    	<div class="input_name outLinkDiv"  style="display:none;">
            <span>外部链接:</span><input type="text" name="outLink" placeholder="外部链接" value='' /><span></span>
          </div><br/>
         <div  class="explain"> 
    		<script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>
		</div>
        <div class="button">
           <a id='submit_form' href="javascript:void(0);"><input  type="button" name="button" value="保存" /></a>
        </div>
   </div></div>  
</div></div> 
<script type="text/javascript">  
$(function(){
	
	var ue = UE.getEditor('editor'); 
	loadallNewsModules();
	function loadallNewsModules(){
		$.ajax({
				url : '${basePath}manager/NewsModules_allNewsModules', 
				data : {
					 
				},
				dataType : "JSON",
				async : true,
				cache : false,  
				type  : "POST",
				success : function(data) {
					if(1==data.code){
						 var html ='<option value="0">------------</option>';
						 $(data.data).each(function(index,bean){
						 		html+='<option value="'+bean.id+'" >'+bean.modulesName+'</option>';
						 });
						 $('select[name=newsModulesId]').html(html);
					}
				}
		});
	}
	
	$('select[name=isOutNews]').change(function(){
		var isOutNews=  $('select[name=isOutNews]').val();
		if(isOutNews==1){
			$('.explain').hide();
			$('.outLinkDiv').show();
		}else{
			$('.explain').show();
			$('.outLinkDiv').hide();
		}
	});
	
	$('#submit_form').click(function(){
    	var newsModulesId=$('select[name=newsModulesId]').val();//父Id
    	var newsTitle  = $('input[name=newsTitle]').val();
    	var customId = $('input[name=customId]').val();
    	var pageViews = $('input[name=pageViews]').val();
    	var newsContent=ue.getContent();//分类简介
		var outLink =$('input[name=outLink]').val();
    	var isOutNews = $('select[name=isOutNews]').val();
		 $.ajax({
				url : 'manager/News_plusNews', 
				data : {
						 customId:customId,
						 newsModulesId:newsModulesId,
						 newsTitle:newsTitle,
						 pageViews:pageViews,
						 newsContent:newsContent,
						 outLink : outLink,
						 isOutNews : isOutNews
				},
				dataType : "JSON",
				async : true,
				cache : false,
				type  : "POST",
				success : function(data) { 
					if(1==data.code){
						 if(confirm("添加成功,是否继续添加?")){
							 window.location.reload();
						 }else{
							  window.location.href="${basePath}manager/News_newsList";
						 }
					}else{
						alert(data.msg);
					}
				}
		}); 
	});
	
}); 
</script>
</body>
</html>